﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.GamerServices;

namespace The_Square_Saga.Screens
{
    class ScreenManager
    {
        /// <summary>
        /// The current screen
        /// </summary>
        private static Screen currentScreen;
        private static GameWindow Window;
        /// <summary>
        /// The content for load
        /// </summary>
        private static ContentManager contentManager;

        public ScreenManager(ContentManager content, GameWindow window)
        {
            contentManager = content;
            Window = window;
        }

        /// <summary>
        /// Sets the current screen
        /// </summary>
        /// <param name="name">A screen name</param>
        public static void setCurrentScreen(ScreenName name)
        {
            if (ScreenName.GAME_SCREEN == name)
            {
                GameScreen gameScreen = new GameScreen(null, Window);
                gameScreen.load(contentManager);
                currentScreen = gameScreen;
            }
        }

        /// <summary>
        /// Clean the screen
        /// </summary>
        public void cleanScreen()
        {
            currentScreen = null;
        }

        /// <summary>
        /// Check if the current screen is not null
        /// </summary>
        /// <returns>True if him exists</returns>
        public bool existsCurrentScreen()
        {
            return currentScreen != null;
        }

        /// <summary>
        /// Updates the current screen
        /// </summary>
        public void updateCurrentScreen(GameTime gameTime, GameWindow Window)
        {
            if (existsCurrentScreen())
                currentScreen.update(gameTime, Window);
        }

        /// <summary>
        /// Draws the current screen
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch</param>
        public void drawCurrentScreen(SpriteBatch spriteBatch)
        {
            if (existsCurrentScreen())
                currentScreen.draw(spriteBatch);
        }
    }
}